package logic

import (
	"context"

	"storage/internal/svc"
	"storage/pb/storage"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateBatchLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateBatchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateBatchLogic {
	return &CreateBatchLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// CreateBatch 批量创建
func (l *CreateBatchLogic) CreateBatch(in *storage.BatchOperationRequest) (*storage.Empty, error) {
	err := l.svcCtx.StorageModel.BatchInsert(l.ctx, in.UserId, in.ParentId, in.Status, in.FolderIds, in.FileIds)
	if err != nil {
		return nil, err
	}
	return &storage.Empty{}, nil
}
